package com.example.yls.demoa;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.EditText;

public class updateActivity extends AppCompatActivity{

    private EditText updateStuno;
    private EditText updateName;
    private EditText updateAge;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_update);

        updateStuno = findViewById(R.id.updateStuno);
        updateName = findViewById(R.id.updateName);
        updateAge = findViewById(R.id.updateAge);

        Intent intent = getIntent();
        String stuno = intent.getStringExtra("STUNO");
        String name = intent.getStringExtra("NAME");
        int age = intent.getIntExtra("AGE",0);
        updateStuno.setText(stuno.toString());
        updateName.setText(name.toString());
        updateAge.setText(String.valueOf(age));


        findViewById(R.id.updateStu).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String stuno = updateStuno.getText().toString();
                String name = updateName.getText().toString();
                int age = Integer.parseInt(updateAge.getText().toString());

                Intent intent = new Intent();
                intent.putExtra("STUNO",stuno);
                intent.putExtra("NAME",name);
                intent.putExtra("AGE",age);
                setResult(2002,intent);
                finish();
            }
        });

    }


}
